package com.heyqing.topic.MoveZeroes_0283;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * ClassName:MoveZeroes
 * Package:com.heyqing.topic.MoveZeroes_0283
 * Description:
 *
 * @Date:2024/9/26
 * @Author:Heyqing
 */
public class MoveZeroes {
    public void moveZeroes(int[] nums) {
        List<Integer> notZero = Arrays.stream(nums).filter(n -> n != 0).boxed().collect(Collectors.toList());
        Collections.sort(notZero);
        Arrays.fill(nums,0);
        int index = 0;
        for (Integer integer : notZero) {
            nums[index++] = integer;
        }
    }
}
